﻿
set ProjectDir=C:\Projects\Release v1 DVK.SP2007\DVK.SP2007.v1.Source\Main\Projects\DVK.SP2007
set TargetDir=C:\Projects\Release v1 DVK.SP2007\DVK.SP2007.v1.Source\Main\Projects\DVK.SP2007\bin\Package

set SPAdminTool=%CommonProgramFiles%\Microsoft Shared\web server extensions\12\BIN\stsadm.exe
set PackageName=DVK.SP2007.wsp
set TargetWebUrl=http://vstsdevpercival/
set TargetSiteUrl=http://vstsdevpercival/
set FeatureGuid2=2ED7152D-B201-47A2-AF9D-0AE718EEE962
set FeatureGuid3=F5D0F6EE-2B50-498B-BD40-20CB1541E0E9
set PackageFile=C:\Projects\Release v1 DVK.SP2007\DVK.SP2007.v1.Source\Main\Projects\DVK.SP2007\bin\Package\DVK.SP2007.wsp
    
cd "%ProjectDir%"

"C:\Windows\System32\MAKECAB.EXE" /f DVK.SP2007.ddf

cd "%TargetDir%"

	echo Deactivating feature SP.DVK.Jobid ... Guid="%FeatureGuid3%"
    "%SPAdminTool%" -o deactivatefeature -id "%FeatureGuid3%" -url %TargetSiteUrl%

    echo Uninstalling feature SP.DVK.Jobid ... Guid="%FeatureGuid3%"
    "%SPAdminTool%" -o uninstallfeature -id "%FeatureGuid3%" -force

    echo Deactivating feature SP.DVK ... Guid="%FeatureGuid2%"
    "%SPAdminTool%" -o deactivatefeature -id "%FeatureGuid2%" -url %TargetSiteUrl%

    echo Uninstalling feature SP.DVK ... Guid="%FeatureGuid2%"
    "%SPAdminTool%" -o uninstallfeature -id "%FeatureGuid2%" -force

    echo Retracting solution %PackageName% ...
    "%SPAdminTool%" -o retractsolution -name "%PackageName%" -url %TargetWebUrl% -local 

    echo Deleting solution %PackageName% from SharePoint ...
    "%SPAdminTool%" -o deletesolution -name "%PackageName%"
    
    echo Staring IIS reset
    "C:\Windows\System32\IISReset.exe" /NOFORCE

echo Adding solution %PackageName% to the SharePoint ...
"%SPAdminTool%" -o addsolution -filename "%PackageFile%"

    echo Deploying solution %PackageName% ... 
    "%SPAdminTool%" -o deploysolution -name "%PackageName%" -url %TargetWebUrl% -local -allowGacDeployment 

    echo Activating feature SP.DVK ... Guid="%FeatureGuid2%"
    "%SPAdminTool%" -o activatefeature -id "%FeatureGuid2%" -url %TargetSiteUrl%

    echo Activating feature SP.DVK.Jobid ... Guid="%FeatureGuid3%"
    "%SPAdminTool%" -o activatefeature -id "%FeatureGuid3%" -url %TargetSiteUrl%

	echo Staring IIS reset
    "C:\Windows\System32\IISReset.exe" /NOFORCE

